package eos.dom.server;

import java.util.Collections;
import java.util.Stack;

import javax.jdo.annotations.Element;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable
public class Deck {
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
	
	@Persistent
	@Element(dependent="true")
	private Stack<Integer> deckCards;
	
	public Deck(){
		deckCards = new Stack<Integer>();
		for(int i=0;i<7;i++){
			deckCards.push(CardId.COPPER.ordinal());
		}
		for(int i=0;i<3;i++){
			deckCards.push(CardId.ESTATE.ordinal());
		}
		this.shuffle();
	}

	/**
	 * Shuffles the deck
	 */
	public void shuffle() {
		Collections.shuffle(deckCards);
	}

	public Stack<Integer> getCards() {
		return deckCards;
	}

	public void setCards(Stack<Integer> cards) {
		this.deckCards = cards;
	}

	public boolean isEmpty() {
		return deckCards.isEmpty();
	}

	public Integer pop() {
		return deckCards.pop();
	}

	public void pushAll(Stack<Integer> cards) {
		deckCards.addAll(cards);
	}
	
	
	
	

}

